<?php


namespace App\Models\OpenShop\SiteLocation;


use App\Enums\OpenShop\MissionTemplateEnum;
use App\Models\BaseModel;
use App\Models\OpenShop\InvestmentPromotion\OpenShopUploadFileResourceModel;
use App\Models\Traits\KfSoftDeletes;
use App\Models\Traits\KfUid;
use DateTimeInterface;

class OpenShopSiteLocationCustomerAnalysisModel extends BaseModel
{
    use KfUid;
    use KfSoftDeletes;

    protected $table = 'open_shop_site_location_customer_analysis';

    protected $fillable = [
        'id',
        'orderNo',
        'siteId',
        'time',
        'week',
        'dateType',
        'weather',
        'temperature',
        'afternoonNumber',
        'afternoonYoungProportion',
        'afternoonTeaNumber',
        'afternoonTeaYoungProportion',
        'nightNumber',
        'nightYoungProportion',
        'nightSnackNumber',
        'nightSnackYoungProportion',
        'createdAt',
        'createdByUid',
        'updatedAt',
        'updatedByUid',
    ];

    public static array $filterFields = [
        "afternoonNumber",
        "afternoonYoungProportion",
        "afternoonTeaNumber",
        "afternoonTeaYoungProportion",
        "nightNumber",
        "nightYoungProportion",
        "nightSnackNumber",
        "nightSnackYoungProportion"
    ];

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format("Y-m-d H:i:s");
    }

    public function fileRel()
    {
        return $this->hasMany(OpenShopUploadFileResourceModel::class, 'businessId', 'id');
    }
}
